#include<iostream>
#include<string>
using namespace std;

int firstUniqChar(string s) {
    int size = s.size();
    int arr[26] = { 0 };
    for (int i = 0; i < size; i++)
    {
        ++arr[s[i] - 'a'];
    }
    for (int i = 0; i < 26; i++)
    {
        if (arr[s[i] - 'a'] == 1)
            return i;
    }

    return -1;
}
int main()
{
    //firstUniqChar("aabb");
    /*int arr[2] = { 1,2 };
    arr['b' - 'a'] = 5;*/

    /*char ch[5] = { 'a','b','c','d','z' };
    int arr[26] = { 0 };
    for (int i = 0; i < 5; i++)
    {
        ++arr[ch[i] - 'a'];
    }*/

    /*string s("faen efje fe");
    //int i = 0;
    //size_t pos = s.find_first_of(" ");
    //string tmp = s.substr(0, pos);
    //string::reverse_iterator rit = tmp.rbegin();
    //for (rit; rit != tmp.rend(); ++rit)
    //{
    //    s[i] = *rit;
    //    ++i;
    //}
    //while (pos != string::npos)
    //{
    //    ++i;
    //    size_t postmp = pos;
    //    pos = s.find_first_of(" ", pos + 1);
    //    tmp = s.substr(postmp + 1, pos - postmp - 1);
    //    string::reverse_iterator rit = tmp.rbegin();
    //    for (rit; rit != tmp.rend(); ++rit)
    //    {
    //        s[i] = *rit;
    //        ++i;
    //    }
    //}
    //cout << s << endl;*/

    //string s("fae");
    //cout << s.size();
    //int i = 10;
    //int m = 10;
    //while (i /= 10)
    //{
    //    m *= 10;
    //}
    //std::string base = "this is a test string.";
    //std::string str2 = "n example";

    //size_t pos = base.find_first_of(' ');
   

    //std::string str = base;           // "this is a test string."
    //str.replace(0, pos, str2);

    string num1("112");
    string num2("59");
    int end1 = num1.size() - 1;
    int end2 = num2.size() - 1;
    string mul;
    string str;
    int flag = 0;

    while (end1 >= 0)
    {
        int next = 0;
        end2 = num2.size() - 1;
        int val1 = num1[end1] >= 0 ? num1[end1] - '0' : 0;
        while (end2 >= 0)
        {
            int val2 = num2[end2] >= 0 ? num2[end2] - '0' : 0;
            int ret = val1 * val2 + next;
            next = ret / 10;
            ret = ret % 10;
            str.insert(str.begin(), ret + '0');
            --end2;
        }
        if (next != 0)
        {
            str.insert(str.begin(), next + '0');
        }
        string tmp = mul;
        size_t pos5 = tmp.find_first_of("0");
        while (pos5 != string::npos && flag != 0)
        {
            pos5 = tmp.find_first_of("0", pos5 + 1);
            size_t pos1 = str.find(' ');
            str.insert(pos1, "0");
        }
        ++flag;
        str.insert(str.begin(), ' ');
        mul += "0";
        tmp = mul;
        --end1;
    }

    while (str.find_first_of(" ", 1) != string::npos)
    {
        size_t pos2 = str.find_first_of(" ", 1);
        size_t pos3 = str.find_first_of(" ", pos2 + 1);
        string s1 = str.substr(1, pos2 - 1);
        string s2 = str.substr(pos2 + 1, pos3 - pos2 - 1);

        int end3 = s1.size() - 1;
        int end4 = s2.size() - 1;
        int next2 = 0;
        string str2;
        while (end3 >= 0 || end4 >= 0)
        {
            int val3 = end3 >= 0 ? s1[end3] - '0' : 0;
            int val4 = end4 >= 0 ? s2[end4] - '0' : 0;
            --end3;
            --end4;

            int ret = val3 + val4 + next2;
            next2 = ret / 10;
            ret = ret % 10;

            str2.insert(str2.begin(), ret + '0');
        }
        if (next2 == 1)
        {
            str2.insert(str2.begin(), next2 + '0');
        }
        str.replace(1, pos3 - 1, str2);
    }
    str.erase(str.begin());

    return 0;
}